package com.igfd.tanmao.mapper;

import com.igfd.tanmao.pojo.TamllItem;
import com.igfd.tanmao.pojo.TanmaoItem;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.Date;

@Mapper
public interface TanmaoItemMapper {

    @Insert("insert into tanmao_items(num_iid, sku_id, properties_name, create_at) values(#{numIid}, #{skuId}, #{propertiesName}, #{createAt})")
    int add(@Param("numIid") String numIid, @Param("skuId") String skuId, @Param("propertiesName") String propertiesName, @Param("createAt") Date createAt);

    @Select("select id,spu,product_skc as productSkc from tanmao_items where num_iid = #{numIid} and sku_id = #{skuId}")
    TanmaoItem findTanmaoItemByNumiidAndSkuid(@Param("numIid") String numIid, @Param("skuId") String skuId);

    @Select("select * from tanmao_items")
    ArrayList<TamllItem> findAll();

    @Update("update tanmao_items set last_stock_number = #{number} where num_iid = #{numIid} and sku_id = #{skuId}")
    int updateTmallItemStockNumber(@Param("number") Integer number,@Param("numIid") String numIid, @Param("skuId") String skuId);
}
